package chapter02;

public class Test13_Account {
    public static void main(String[] args) {
        Account a = new Account("张三",
                1000);
        a.deposit(1000);
        System.out.println(a.getBalance());
        a.withdraw(1000);
        System.out.println(a.getBalance());
        a.withdraw(2000);

    }
}
class Account{
    private String accountName;
    private int balance;
    public Account(String accountName, int balance) {
        this.accountName = accountName;
        this.balance = balance;
    }
    public int getBalance(){
        return this.balance;
    }
    public void deposit(int money){
        this.balance = this.balance+money;
    }
    public void withdraw(int money){
        if(this.balance-money<0){
            System.out.println("取款失败，余额不足");
        }else{
            this.balance = this.balance-money;
        }

    }
}
